﻿namespace XYS.Service.Core.EventBus
{
    public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
    {
        /// <summary>
        /// 订阅信息
        /// </summary>
        public class SubscriptionInfo
        {
            /// <summary>
            /// 是否动态
            /// </summary>
            public bool IsDynamic { get; }
            /// <summary>
            /// 类型
            /// </summary>
            public Type HandlerType { get; }

            /// <summary>
            /// 
            /// </summary>
            /// <param name="isDynamic"></param>
            /// <param name="handlerType"></param>
            private SubscriptionInfo(bool isDynamic, Type handlerType)
            {
                IsDynamic = isDynamic;
                HandlerType = handlerType;
            }

            /// <summary>
            /// 动态
            /// </summary>
            /// <param name="handlerType"></param>
            /// <returns></returns>
            public static SubscriptionInfo Dynamic(Type handlerType) =>
              new SubscriptionInfo(true, handlerType);

            /// <summary>
            /// 类型
            /// </summary>
            /// <param name="handlerType"></param>
            /// <returns></returns>
            public static SubscriptionInfo Typed(Type handlerType) =>
                new SubscriptionInfo(false, handlerType);
        }
    }
}
